package cn.haulon.express;

/**
 * Created by Haulon on 18/09/2017.
 * <p>
 * Used as ...
 */
public class ExpressFactory {
    private static final ExpressManager manager = ExpressManager.me();

    @SuppressWarnings({"WeakerAccess", "unused"})
    public static Express getServer(String serverKey) {
        return manager.get(serverKey);
    }

    @SuppressWarnings("unused")
    public static Express getServer(Class<? extends Express> expressClass) {
        Express express = manager.get(expressClass.getName());
        if (express == null) try {
            express = expressClass.newInstance();
            manager.put(expressClass.getName(), express);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return express;
    }
}
